﻿using System;
using System.Collections;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using T2.WebSecurity.Business;
using T2.WebSecurity.Business.Entities;
using T2.WebSecurity.Business.Entities.Interfaces;
using T2.WebSecurity.Business.Entities.Search;
using T2.WebSecurity.Business.Entities.Search.Interfaces;


namespace T2.WebSecurity.Test
{
    [TestClass]
    public class TestProvidersAndBusinessServices
    {
        BusinessService bs = new BusinessService();
        [TestMethod]
        public void AddApplication()
        {
            T2.WebSecurity.Business.Entities.Interfaces.IApplication_biz param = new Application_biz();
            param.Action = "Add";
            param.ApplicationName = "T2Logging";
            param.CreatedBy = "trooks";
            param.CreatedDt = System.DateTime.Now; 
            param.ModifiedBy = "trooks";
            param.ModifiedDt = System.DateTime.Now;
            IDictionary<string, int> retVal = bs.ApplicationController_Set(param);
            Assert.Inconclusive();
        }

        [TestMethod]
        public void UpdateApplication()
        {
            IApplication_biz param = GetTopApp();
            param.Action = "Update";
            //param.ApplicationName = "TracyUpdated";
            param.ModifiedBy = "trooks";
            param.ModifiedDt = System.DateTime.Now; 
            IDictionary<string, int> retVal = bs.ApplicationController_Set(param);
            Assert.Inconclusive();
        }

        [TestMethod]
        public void GetAllApplications()
        {
            IApplication_biz param = new Application_biz();
            param.Action = "GetAll";
            param.PageNumber = 1;
            param.PageSize = 100;
            param.SortColumn = "ApplicationID";
            param.SortType = "asc";
            List<IApplication_biz> retVal = bs.ApplicationController_Get(param, false, false);
            Assert.Inconclusive();
        }

        

        [TestMethod]
        public void GetOneApplication()
        {
            IApplication_biz param = GetTopApp();
            param.Action = "Modify";
            param.ModifiedBy = "trooks";
            param.ModifiedDt = System.DateTime.Now;
            List<IApplication_biz> retVal = bs.ApplicationController_Get(param, true, true);
            Assert.Inconclusive();
        }

        [TestMethod]
        public void SearchApplication()
        {
            IApplicationSearch_biz param = new ApplicationSearch_biz(); ;
            param.Action = "Search";
            param.ApplicationName = "T2";
            param.PageNumber = 1;
            param.PageSize = 100;
            param.SortColumn = "ApplicationID";
            param.SortType = "asc";
            List<IApplication_biz> retVal = bs.ApplicationController_Search(param, true, true);
            Assert.Inconclusive();
        }

        private IApplication_biz GetTopApp()
        {
            IApplication_biz param = new Application_biz();
            param.Action = "GetAll";
            param.PageNumber = 1;
            param.PageSize = 100;
            param.SortColumn = "ApplicationID";
            param.SortType = "asc";
            List<IApplication_biz> retVal = bs.ApplicationController_Get(param, true, true);
            return retVal[0];
        }


       
    }
}
